
package com.shop.cloud.mall.admin.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shop.cloud.common.core.util.R;
import com.shop.cloud.common.log.annotation.SysLog;
import com.shop.cloud.mall.common.entity.BalanceRechargeConfig;
import com.shop.cloud.mall.admin.service.BalanceRechargeConfigService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

/**
 * 余额充值配置
 *
 * @author
 * @date 2023-11-01 10:39:58
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/balancerechargeconfig")
@Tag(description = "balancerechargeconfig", name = "余额充值配置管理")
public class BalanceRechargeConfigController {

    private final BalanceRechargeConfigService balanceRechargeConfigService;

    /**
     * 余额充值配置分页列表
     * @param page 分页对象
     * @param balanceRechargeConfig 余额充值配置
     * @return
     */
    @Operation(summary = "余额充值配置分页列表")
    @GetMapping("/page")
    @PreAuthorize("@ato.hasAuthority('mall:balancerechargeconfig:index')")
    public R getPage(Page page, BalanceRechargeConfig balanceRechargeConfig) {
        return R.ok(balanceRechargeConfigService.page(page, Wrappers.query(balanceRechargeConfig)));
    }

    /**
     * 余额充值配置查询
     * @param id
     * @return R
     */
    @Operation(summary = "余额充值配置查询")
    @GetMapping("/{id}")
    @PreAuthorize("@ato.hasAuthority('mall:balancerechargeconfig:get')")
    public R getById(@PathVariable("id") String id) {
        return R.ok(balanceRechargeConfigService.getById(id));
    }

    /**
     * 余额充值配置新增
     * @param balanceRechargeConfig 余额充值配置
     * @return R
     */
    @Operation(summary = "余额充值配置新增")
    @SysLog("新增余额充值配置")
    @PostMapping
    @PreAuthorize("@ato.hasAuthority('mall:balancerechargeconfig:add')")
    public R save(@RequestBody BalanceRechargeConfig balanceRechargeConfig) {
        return R.ok(balanceRechargeConfigService.save(balanceRechargeConfig));
    }

    /**
     * 余额充值配置修改
     * @param balanceRechargeConfig 余额充值配置
     * @return R
     */
    @Operation(summary = "余额充值配置修改")
    @SysLog("修改余额充值配置")
    @PutMapping
    @PreAuthorize("@ato.hasAuthority('mall:balancerechargeconfig:edit')")
    public R updateById(@RequestBody BalanceRechargeConfig balanceRechargeConfig) {
        return R.ok(balanceRechargeConfigService.updateById(balanceRechargeConfig));
    }

    /**
     * 余额充值配置删除
     * @param id
     * @return R
     */
    @Operation(summary = "余额充值配置删除")
    @SysLog("删除余额充值配置")
    @DeleteMapping("/{id}")
    @PreAuthorize("@ato.hasAuthority('mall:balancerechargeconfig:del')")
    public R removeById(@PathVariable String id) {
        return R.ok(balanceRechargeConfigService.removeById(id));
    }

}
